<!--
 * @Author: 瞿旺兴 18774621495@163.com
 * @Date: 2022-05-20 16:04:43
 * @LastEditors: 瞿旺兴 18774621495@163.com
 * @LastEditTime: 2022-06-08 17:38:25
 * @FilePath: \nien-vue3-admin\src\views\finance\receiverManame\reconciliationManagement\Receivable\staticsManage\generalSummary\components\DetailDialog.vue
 * @Description: 提单报表详情
-->
<template>
  <el-dialog v-model="visible" title="详情">
    <custom-container :config="config" />
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, computed, reactive, defineExpose, getCurrentInstance } from 'vue'
import { getSummaries } from '@/utils'

const visible = ref<boolean>(false)
const {
  appContext: {
    config: {
      globalProperties: { $download },
    },
  },
} = getCurrentInstance()
const queryParams = reactive({
  pageSize: 10,
  pageNum: 1,
  customerName: undefined,
  serialNo: undefined,
  ywymc: undefined,
  endDate: undefined,
  sszd: undefined,
  zdzt: undefined,
  qd: undefined,
})
const exportLoading = ref<boolean>(false)
const config = computed({
  get() {
    return {
      query: {
        fields: [
          {
            type: 'date-picker',
            label: '业务开始时间',
            prop: 'endDate',
            option: {
              type: 'date',
            },
          },
          {
            type: 'date-picker',
            label: '业务结束时间',
            prop: 'endDate',
            option: {
              type: 'date',
            },
          },
          {
            label: '客户名称',
            prop: 'customerName',
          },
          {
            label: '客户单号',
            prop: 'customerName',
          },
          {
            label: '转单号',
            prop: 'customerName',
          },
          {
            label: '销售产品',
            prop: 'customerName',
          },
        ],
        queryParams,
        formOption: {},
      },
      btns: [
        {
          title: '导出',
          type: 'primary',
          loading: exportLoading.value,
          onClick: (e) => {
            exportLoading.value = true
            const data = queryParams
            $download(
              'finance/seaAirTransportFinanceAccount/listExport', 
              data, 
              `空海运账单_${ new Date().getTime() }.xlsx`,
            )
            .finally(() => {
              exportLoading.value = false
            })
          },
        },
      ],
      table: {
        columns: [
          { label: '业务日期', align: 'center', prop: 'endDate' },
          { label: '客户名称', align: 'center', prop: 'endDate' },
          { label: '单价', align: 'center', prop: 'customerCode' },
          { label: '计费重', align: 'center', prop: 'customerCode' },
          { label: '单票总金额', align: 'center', prop: 'customerCode' },
          { label: '附加费', align: 'center', prop: 'customerCode' },
          { label: '应收总金额', align: 'center', prop: 'customerCode' },
          { label: '客户单号', align: 'center', prop: 'customerCode' },
          { label: '转单号', align: 'center', prop: 'customerName' },
          { label: '销售产品', align: 'center', prop: 'paidAmount' },
          { label: '国家', align: 'center', prop: 'totalVotes' },
          { label: '邮编', align: 'center', prop: 'totalPiece' },
          { label: '品名', align: 'center', prop: 'totalChargeWeight' },
          { label: '报关件', align: 'center', prop: '' },
        ],
        event: {
          showSummary: true,
          summaryMethod: getSummaries(['receivingTotalWeight']),
        },
      },
      api: () => Promise.resolve({ code: 200, data: [{}] }),
    }
  },
  set(val) {
    return val
  },
})

const open = () => {
  visible.value = true
}

defineExpose({
  open,
})
</script>